package com.pig4cloud.pigx.strategy.api.feign;

import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pigx.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;

/**
 * 策略模块-策略-合约feign接口
 *
 * @since 2022/8/28 16:47
 */
@FeignClient(contextId = "strategyContractFeign",
		value = ServiceNameConstants.STRATEGY_SERVICE,
		path = "/feign/strategy/contract")
public interface StrategyContractFeign {

	/**
	 * 根据产品id统计相关策略的条数
	 * <p>相关逻辑：删除产品
	 */
	String COUNT_BY_PRODUCT_ID = "/count/by-product-id";
	String USER_START_STRATEGY_COUNT = "/user/start/strategy";
	String USER_CONTRACT_PROFIT = "/user/contract/profit";

	/**
	 * 根据产品id统计相关策略的条数
	 *
	 * @param productId 产品id
	 * @param from      标记系统内部请求
	 * @return {@link R< Long>}
	 * @since 2022/11/26 14:41
	 */
	@GetMapping(COUNT_BY_PRODUCT_ID)
	R<Long> countByProductId(@RequestParam("productId") Long productId, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 获取用户正在进行的策略数量
	 * @param userId 用户id
	 * @param from from
	 * @return r
	 */
	@GetMapping(USER_START_STRATEGY_COUNT)
	R<Long> userStartStrategyCount(@RequestParam("userId") Long userId, @RequestHeader(SecurityConstants.FROM) String from);


	/**
	 * 获取用户累计利润
	 * @param userId 用户id
	 * @param from from
	 * @return r
	 */
	@GetMapping(USER_CONTRACT_PROFIT)
	R<BigDecimal> userContractProfit(@RequestParam("userId") Long userId, @RequestHeader(SecurityConstants.FROM) String from);
}
